package com.sjn.manage.controller;

import com.codingapi.txlcn.tc.annotation.TxTransaction;
import com.sjn.manage.config.GitConfig;
import com.sjn.manage.mapper.TestMapper;
import io.netty.handler.timeout.TimeoutException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Enumeration;
import java.util.Random;
import java.util.Scanner;

/**
 * @Author: sjn
 * @Data: 2021/6/15 10:44
 */
@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    private TestMapper mapper;

    @Autowired
    private GitConfig gitConfig;

    @RequestMapping("")
    public Object test(HttpServletRequest request) {
        Enumeration<String> headerNames = request.getHeaderNames();
        return "manage, " + gitConfig.getUsername() + ", " + gitConfig.getPassword() + ", " + gitConfig.getEnv();
    }

    @RequestMapping("heath")
    public Object heath() {
        return "OK";
    }

    @RequestMapping("sqlTest")
//    @TxTransaction
    public Object sqlTest() {
        System.out.println("接口调用");
//        mapper.insert();

        try {
            Thread.sleep(10*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        int a = 1;
        Integer b = null;
//        a = b;
        int count = mapper.selectCount();
        return count;
    }
}
